package com.fast.alden.portal.entity.dto;

import com.fast.alden.data.model.PortalUser;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

@Data
public class RegisterParam implements Serializable {
    /**
     * 用户名
     */
    @NotBlank
    private String username;
    /**
     * 密码
     */
    @NotBlank
    private String password;
    /**
     * 昵称
     */
    private String nickname;
    /**
     * 真实姓名
     */
    private String realName;
    /**
     * 邮箱
     */
    @NotBlank
    private String email;
    /**
     * 电话
     */
    @NotBlank
    private String phone;
    /**
     * 生日
     */
    private LocalDate birthday;
    /**
     * 个人介绍
     */
    private String introduce;
    /**
     * 验证码key
     */
    @NotBlank
    private String verifyCodeKey;
    /**
     * 验证码
     */
    @NotBlank
    private String verifyCode;

    public static PortalUser convert(RegisterParam param) {
        PortalUser user = new PortalUser();
        user.setUsername(param.getUsername());
        user.setPassword(param.getPassword());
        user.setNickname(param.getNickname());
        user.setRealName(param.getRealName());
        user.setEmail(param.getEmail());
        user.setPhone(param.getPhone());
        user.setBirthday(param.getBirthday());
        user.setIntroduce(param.getIntroduce());
        user.setStatus(1);

        return user;
    }
}
